package org.glow.changgou.goods.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.glow.changgou.goods.pojo.Sku;
import org.glow.changgou.order.pojo.OrderItem;
import org.springframework.stereotype.Service;

/****
 * @Author:admin
 * @Description:Sku的Dao
 * @Date 2022/09/24 14:20:10
 *****/
@Mapper
public interface SkuMapper extends BaseMapper<Sku> {
    /**
     * 递减库存
     * @param orderItem
     * @return
     */
    @Update("UPDATE tb_sku SET num=num-#{num},sale_num=sale_num+#{num} WHERE id=#{skuId} AND num>=#{num}")
    int decrCount(OrderItem orderItem);
}
